\chapter{简单的使用例子}
\label{cha:usage-example}

正文

\section{图像的插入}

\subsection{镶嵌在文中的图像}
\begin{wrapfigure}{r}{0.5\linewidth}
    \centering
    \includegraphics[width=0.5\textwidth]{image/chap04/confusion.pdf}
    \caption{镶嵌在文中的图像}
    \label{fig:image-embedding-text}
\end{wrapfigure}


\subsection{单张图像的插入}

\begin{figure}[h]
    \centering
    \includegraphics[width=0.5\textwidth]{image/chap04/illustration/hole.pdf}
    \caption{单张图像}
    \label{fig:hole}
\end{figure}


\subsection{多张图像的并排插入}


\begin{figure}[h!]%文中的Grid-LSTM模型做的语义图像分割的例子
    \centering
    \includegraphics[width=.2\textwidth,height=.15\textwidth]{image/chap04/example/2007_000799.jpg}
    \includegraphics[width=.2\textwidth,height=.15\textwidth]{image/chap04/example/2007_002094.jpg}
    \includegraphics[width=.2\textwidth,height=.15\textwidth]{image/chap04/example/2007_004483.jpg}
    \includegraphics[width=.2\textwidth,height=.15\textwidth]{image/chap04/example/2007_003194.jpg}
    \\
    \includegraphics[width=.2\textwidth,height=.15\textwidth]{image/chap04/example/2007_000799.pdf}
    \includegraphics[width=.2\textwidth,height=.15\textwidth]{image/chap04/example/2007_002094.pdf}
    \includegraphics[width=.2\textwidth,height=.15\textwidth]{image/chap04/example/2007_004483.pdf}
    \includegraphics[width=.2\textwidth,height=.15\textwidth]{image/chap04/example/2007_003194.pdf}
    \caption{并排的多张图像}
    \label{fig:multi-image-example1}
\end{figure}


\begin{figure}[h]
    \centering
    \makebox[0.11\textwidth]{\scriptsize 图像}
    \enspace
    \makebox[0.11\textwidth]{\scriptsize 真值}
    \enspace
    \makebox[0.11\textwidth]{\scriptsize CNN+5LSTM\textbf{1}}
    \enspace\thinspace
    \makebox[0.11\textwidth]{\scriptsize CNN+5LSTM\textbf{2}}
    \enspace\thinspace
    \makebox[0.11\textwidth]{\scriptsize CNN+5LSTM\textbf{3}}
    \enspace\thinspace
    \makebox[0.11\textwidth]{\scriptsize CNN+5LSTM\textbf{4}}
    \enspace\thinspace
    \makebox[0.11\textwidth]{\scriptsize CNN+5LSTM\textbf{5}}\\
    \includegraphics[width=0.11\textwidth]{image/chap04/improvement/2007_000663.jpg}
    \enspace\thinspace %\hfill
    \includegraphics[width=0.11\textwidth]{image/chap04/improvement/2007_000663.png}
    \enspace\thinspace
    \includegraphics[width=0.11\textwidth]{image/chap04/improvement/2007_000663_1.png}
    \enspace\thinspace
    \includegraphics[width=0.11\textwidth]{image/chap04/improvement/2007_000663_2.png}
    \enspace\thinspace
    \includegraphics[width=0.11\textwidth]{image/chap04/improvement/2007_000663_3.png}
    \enspace\thinspace
    \includegraphics[width=0.11\textwidth]{image/chap04/improvement/2007_000663_4.png}
    \enspace\thinspace
    \includegraphics[width=0.11\textwidth]{image/chap04/improvement/2007_000663_5.png}
    \enspace\thinspace
    \caption{并排的多张图像加各自的注解}
    \label{fig:improvement}
\end{figure}


\subsection{两列图像的插入}

\begin{figure}[h!] % image examples & compare
    \begin{subfigure}{0.55\textwidth}
        \makebox[0.18\textwidth]{\scriptsize Grid-5LSTM}
        \makebox[0.18\textwidth]{\scriptsize FCN-8s\cite{long2015fully}}
        \makebox[0.18\textwidth]{\scriptsize SDS\cite{hariharan2014simultaneous}}
        \makebox[0.18\textwidth]{\scriptsize 真值}
        \makebox[0.18\textwidth]{\scriptsize 图像} \\
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/my_horse.pdf}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/fcn_horse.png}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/sds_horse.png}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/gt_horse.pdf}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/im_horse.pdf}
        \\
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/my_motor.png}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/fcn_motor.png}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/sds_motor.png}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/2007_005173.png}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/2007_005173.jpg}
        \\
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/my_sheep.pdf}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/fcn_sheep.png}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/sds_sheep.png}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/gt_sheep.pdf}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/im_sheep.pdf}
        \\
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/my_boat.png}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/fcn_boat.png}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/sds_boat.png}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/2007_004241.png}
        \includegraphics[width=0.18\textwidth]{image/chap04/result/compare/2007_004241.jpg}
        \caption{左边的图像}
        \label{fig:compare1}
    \end{subfigure}
    \begin{subfigure}{0.4\textwidth}
        \centering
        %		\makebox[0.3\textwidth]{} \\
        %		\makebox[0.3\textwidth]{} \\
        \includegraphics[width=0.25\textwidth]{image/chap04/result/compare/2010_005284.jpg}
        \includegraphics[width=0.25\textwidth]{image/chap04/result/compare/2007_003349.jpg}
        \includegraphics[width=0.25\textwidth]{image/chap04/result/compare/2009_004507.jpg}
        \\
        \includegraphics[width=0.25\textwidth]{image/chap04/result/compare/2010_005284.png}
        \includegraphics[width=0.25\textwidth]{image/chap04/result/compare/2007_003349.png}
        \includegraphics[width=0.25\textwidth]{image/chap04/result/compare/2009_004507.png} \\
        \includegraphics[width=0.25\textwidth]{image/chap04/result/compare/zoom_bus.png}
        \includegraphics[width=0.25\textwidth]{image/chap04/result/compare/zoom_bird.png}
        \includegraphics[width=0.25\textwidth]{image/chap04/result/compare/zoom_dog.png} \\
        \includegraphics[width=0.25\textwidth]{image/chap04/result/compare/deeplab_bus.png}
        \includegraphics[width=0.25\textwidth]{image/chap04/result/compare/deeplab_bird.png}
        \includegraphics[width=0.25\textwidth]{image/chap04/result/compare/deeplab_dog.png} \\
        \includegraphics[width=0.25\textwidth]{image/chap04/result/compare/my_bus.png}
        \includegraphics[width=0.25\textwidth]{image/chap04/result/compare/my_bird.png}
        \includegraphics[width=0.25\textwidth]{image/chap04/result/compare/my_dog.png}
        \caption{右边的图像}
        \label{fig:compare2}
    \end{subfigure}
    \caption{复杂的两列对象的插入}
    \label{fig:complex}
\end{figure}


\clearpage

\section{表格的插入}

\begin{table}[h] %voc table result
    \centering
    \caption{典型的实验对比表格}
    \begin{tabular}{*{4}{c}}
        \toprule
        Method                                & Pixel Acc.    & Mean Acc.     & Mean Iu.      \\
        \midrule
        Liu等人\cite{liu2011sift}             & 76.7          & -             & -             \\
        Tighe等人\cite{tighe2013finding}      & 78.6          & 39.2          & -             \\
        FCN-16s\cite{long2015fully}           & 85.2          & \textbf{51.7} & 39.5          \\
        Deeplab-LargeFOV\cite{chen14semantic} & 85.6          & 51.2          & 39.7          \\
        \midrule
        Grid-LSTM5                            & \textbf{86.2} & 51.0          & \textbf{41.2} \\
        \bottomrule
    \end{tabular}
    \label{tab:siftflow}
\end{table}

\begin{table}[h] %voc table result
    \centering
    \caption{复杂一些的表格}
    \resizebox{\textwidth}{!}{
        \begin{tabular}{c|*{20}{c}|c}
            \toprule
            Method                    & aero          & bike          & bird          & boat          & bottle        & bus           & car           & cat           & chair         & cow           & table         & dog           & horse         & mbike         & person        & plant         & shep          & sofa          & train         & tv            & mIoU.         \\
            \midrule
            CNN                       & 72.6          & 29.6          & 70.2          & 53.1          & 65.1          & 81.0          & 74.3          & 79.8          & 25.0          & 64.8          & 47.8          & 69.5          & 66.2          & 65.2          & 74.2          & 42.1          & 69.6          & 38.8          & 74.4          & 58.6          & 62.5          \\
            CNN+\textbf{1}LSTM        & 71.5          & 30.6          & 70.5          & 53.8          & 64.9          & 82.4          & 77.1          & 79.5          & 25.1          & 65.8          & 47.8          & 71.5          & 64.6          & 67.0          & 74.0          & 43.9          & 69.6          & 38.6          & 74.9          & 59.4          & 63.0          \\
            CNN+\textbf{2}LSTM        & 76.1          & 32.6          & 72.1          & 57.0          & 65.3          & 83.6          & 75.4          & 81.7          & 24.7          & 69.3          & 47.5          & 72.3          & 68.9          & 69.5          & 74.7          & 41.5          & 69.8          & 38.3          & 77.8          & 62.1          & 64.3          \\
            CNN+\textbf{3}LSTM        & 77.7          & 32.3          & 72.6          & 60.0          & 68.3          & 85.5          & 78.5          & 82.3          & 25.3          & 71.1          & 49.7          & 71.5          & 69.7          & 70.8          & 75.9          & 47.9          & 71.2          & 38.9          & 80.2          & 61.7          & 65.8          \\
            CNN+\textbf{4}LSTM        & 79.1          & \textbf{33.7} & \textbf{73.6} & \textbf{62.0} & \textbf{70.4} & 85.5          & \textbf{80.9} & 83.7          & \textbf{24.1} & 70.7          & 45.7          & 73.7          & 69.6          & 72.1          & 75.6          & 47.2          & \textbf{76.0} & 37.3          & 80.5          & 62.2          & 66.4          \\
            CNN+\textbf{5}LSTM        & \textbf{79.9} & 33.6          & \textbf{73.6} & 61.7          & 68.0          & \textbf{88.5} & \textbf{80.9} & \textbf{84.0} & 23.6          & \textbf{71.3} & \textbf{49.7} & \textbf{73.1} & \textbf{71.3} & \textbf{72.9} & \textbf{76.4} & \textbf{48.9} & 75.1          & \textbf{38.1} & \textbf{84.5} & \textbf{63.8} & \textbf{67.2} \\
            \midrule
            CNN+\textbf{5}LSTM$^\dag$ & 84.8          & 36.4          & 82.0          & 69.4          & 73.0          & 87.2          & 81.8          & 86.1          & 34.5          & 82.4          & 53.1          & 81.5          & 77.4          & 79.0          & 81.3          & 54.8          & 81.1          & 47.0          & 84.3          & 67.3          & 72.3          \\
            \bottomrule
        \end{tabular}}
    \label{tab:vocval}
\end{table}


\section{公式}
\label{sec:formula}
没有编号的公式
\begin{align*}
    \begin{split}
        \label{eq:feedforward}
        \mybold{z}^{(l)} & = \mybold{W}^{(l)}\mybold{a}^{(l-1)} + \mybold{b}^{(l)} \\
        \mybold{a}^{(l)} & = f(\mybold{z}^{(l)})
    \end{split}
\end{align*}
公式中含有中文
\begin{align}
    \begin{split}
        \mbox{像素准确率} &= \sum_{i=1}^{n_{cl}}n_{ii} / \sum_{i=1}^{n_{cl}}t_i \\
        \mbox{平均像素准确率} &= \frac{1}{n_{cl}} \sum_{i=1}^{n_{cl}}(n_{ii}/ t_i) \\
        \mbox{Mean IU} &= \frac{1}{n_{cl}} \sum_{i=1}^{n_{cl}}\frac{n_{ii}}{t_i + \sum_j^{n_{cl}} n_{ji} - n_{ii}}
    \end{split}
\end{align}
公式中含有矩阵
\begin{equation}
    \textbf{H} = \begin{bmatrix}
        I*\mybold{x}_i \\ \textbf{h}
    \end{bmatrix}
\end{equation}
每行后面都有编号的公式
\begin{align}
    \frac{\partial}{\partial W_{ij}^{(l)}} J(\mybold{W},\mybold{b};\mybold{x},y) & = \frac{\partial J(\mybold{W},\mybold{b};\mybold{x},y)}{\partial z_i^{(l+1)}}\cdot \frac{\partial z_i^{(l+1)}}{\partial W_{ij}^{(l)}} = \delta_i^{(l+1)}a_j^{(l)} \\
    \frac{\partial}{\partial b_i^{(l)}} J(\mybold{W},\mybold{b};\mybold{x},y)    & = \frac{\partial J(\mybold{W},\mybold{b};\mybold{x},y)}{\partial z_i^{(l+1)}}\cdot \frac{\partial z_i^{(l+1)}}{\partial b_i^{(l)}} = \delta_i^{(l+1)}
\end{align}

\section{算法流程图}
\label{sec:algorithm}
\begin{algorithm}[h]
    \KwIn{$m$个训练样本}
    \lFor{$l=1$ \emph{\KwTo} $n_l$}{
        初始化：$\Delta \mybold{W}^{(l)}=0$，$\Delta \mybold{b}^{(l)}=0$}
    \ForEach{训练样本}{
        \lFor{$l=1$ \emph{\KwTo} $n_l-1$}{
            前向传播：$\mybold{z}^{(l+1)}=\mybold{W}^la^l+\mybold{b}^l$,$\mybold{a}^{(l+1)}=f(\mybold{z}^{(l+1)})$}
        输出误差计算：$\delta^{(n_l)} = \frac{\partial}{\partial \mybold{z}^{(n_l)}} J(\mybold{W},\mybold{b};\mybold{x},y)$\;
        \lFor{$l=n_l-1$ \emph{\KwTo} $1$}{
            后向传播：$\delta^{(l)} = \bigl((\mybold{W}^{(l)})^T \delta^{(l+1)}\bigr)f'(\mybold{z}^{(l)})$}
        \ForAll{层l}{
            计算梯度：$\nabla_{\mybold{W}^{(l)}}J(\mybold{W},\mybold{b};\mybold{x},y)=\delta^{(l+1)}(\mybold{a}^{(l)})^T$ \\
            \hspace{60pt}$\nabla_{\mybold{b}^{(l)}}J(\mybold{W},\mybold{b};\mybold{x},y)=\delta^{(l+1)}$\;
            累加梯度：$\Delta \mybold{W}^{(l)} \leftarrow \Delta \mybold{W}^{(l)} + \nabla_{\mybold{W}^{(l)}}J(\mybold{W},\mybold{b};\mybold{x},y)$; \\
            \hspace{60pt}$\Delta \mybold{b}^{(l)} \leftarrow \Delta \mybold{b}^{(l)} + \nabla_{\mybold{b}^{(l)}}J(\mybold{W},\mybold{b};\mybold{x},y)$\;
        }
    }
    \ForAll{层$l$}{
        更新权重：$\mybold{W}^{(l)} \leftarrow \mybold{W}^{(l)} - \alpha \biggl[\frac 1m \Delta \mybold{W}^{(l)}\biggr]$ \\
        \hspace{60pt} $\mybold{b}^{(l)} \leftarrow \mybold{b}^{(l)} - \alpha \biggl[\frac 1m \Delta \mybold{b}^{(l)}\biggr]$
    }
    \caption{梯度下降算法}
    \label{algo:sgd}
\end{algorithm}

\section{例子、定理与证明}

\begin{eg}
    这是一个例子, 用以验证特殊环境的字体成功更改为楷体.
\end{eg}

\begin{theorem}[定理例子]
    \label{the:example-theorem}
    这是一个定理。
\end{theorem}

\begin{corollary}[推论例子]
    \label{the:example-corollary}
    这是一个推论。
\end{corollary}

\begin{lemma}[引理例子]
    \label{the:example-lemma}
    这是一个引理。
\end{lemma}

这里我们先给出\autoref{the:example-theorem-sysu-thesis}

\begin{theorem}[中山大学毕业论文模板定理]
    \label{the:example-theorem-sysu-thesis}
    中山大学 \LaTeX 毕业论文模板\cite{sysu-thesis}可以用于写各种证明。
\end{theorem}

下面我们对\autoref{the:example-theorem-sysu-thesis}进行证明：


\begin{proof}

    下面我们开始证明：

    由本定理的证明可见，我可以引用\autoref{the:example-theorem}和引理\ref{the:example-corollary}以及推论\ref{the:example-lemma}来证明我这个 \LaTeX 可以用来写各种证明。 \\

    \autoref{the:example-theorem-sysu-thesis}得证。
\end{proof}

\section{代码}

本模版支持在论文中插入代码片段，或直接从源码文件进行插入。
例如，在论文中插入代码片段的效果为：
\begin{python}
    def func():
    print("hello world")
    with open('./output.txt', 'w') as f:
    L = f.readlines()

    if __name__ == "__main__":
    # this is a comment line
    func()
\end{python}
也可在行内插入代码片段，例如：Python中重载加法运算符的函数为\pyinline{__add__}，类的标识符为\pyinline{class}。
此外，还可直接插入代码文件，例如插入\texttt{./code/demo.cpp}的效果为：
\lstinputlisting[style=sysucpp]{code/demo.cpp}


\section{其他的一些用法}
\label{sec:font}
\subsection{子章节编号}
\label{sec:font:subsection}
\subsubsection{更小的章节}
\label{sec:font:subsection:subsub}
更小的章节编号也是支持的。

可以如此引用章节：

\begin{itemize}
    \item \autoref{cha:usage-example}
    \item  \autoref{sec:font}
    \item  \autoref{sec:font:subsection}
    \item  \autoref{sec:font:subsection:subsub}
\end{itemize}


\subsection{列表的使用}
\label{sec:font:list}

这是一个无序列表
\begin{itemize}
    \item 引用文献\cite{long2015fully}
    \item 引用文献作者\citeauthor{long2015fully}
    \item 引用文献年份\citeyear{long2015fully} 
    \item 字体{\color{red}{变红}}，\textbf{粗体}，\textit{斜体}，\underline{下划线}。
\end{itemize}

这是一个有序列表
\begin{enumerate}
    \item 索引前面的\autoref{sec:formula}、图像\ref{fig:complex}、表格\ref{tab:siftflow}
    \item 加脚注\footnote{测{\zihao{-5}试一下}脚注和URL \url{http://cs231n.github.io/transfer-learning/}}
\end{enumerate}


